package mb.model;

import java.awt.Color;
import java.awt.Dimension;
// import java.awt.Point;  // -
import javax.swing.JPanel;

public class Box extends JPanel {

  public static final Color DEFAULT_COLOR = Color.YELLOW;
  public static final Color SELECTION_COLOR = Color.RED;
  public static final Dimension BOX_SIZE = new Dimension(100, 50);
  // public static final Point BOX_LOCATION = new Point(40, 20);  // -

  private Color currentColor = Color.YELLOW;
  private boolean selected = false;

  public Box() {
    super();
    this.setSize(BOX_SIZE);
    this.setCurrentColor(DEFAULT_COLOR);
    // this.setLocation(BOX_LOCATION);  // -
  }

  public Color getCurrentColor() {
    return currentColor;
  }

  public void setCurrentColor(Color aColor) {
    if (aColor != SELECTION_COLOR) {
      currentColor = aColor;
      this.setBackground(aColor);
    }
    this.repaint();
  }

  public boolean isSelected() {
    return selected;
  }

  public void setSelected(boolean aSelected) {
    selected = aSelected;
    if (selected) {
      this.setBackground(SELECTION_COLOR);
    }
    else {
      this.setBackground(currentColor);
    }
    this.repaint();
  }
  
}
